package c.j.a.d.b.j;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.database.sqlite.SQLiteException;
import android.os.Looper;
import android.os.Message;
import android.util.SparseArray;
import c.j.a.c.y.a.i;
import c.j.a.d.b.b.g;
import c.j.a.d.b.b.h;
import c.j.a.d.b.e.n;
import c.j.a.d.b.m.f;
import c.j.a.d.b.n.c0;
import c.j.a.d.b.o.d;
import com.ss.android.socialbase.downloader.impls.DownloadHandleService;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.LinkedBlockingDeque;

/* compiled from: AbsDownloadEngine */
public abstract class c implements c.j.a.d.b.m.f.a {
    public final SparseArray<c.j.a.d.b.h.c> a = new SparseArray();
    public final SparseArray<c.j.a.d.b.h.c> b = new SparseArray();
    public final SparseArray<c.j.a.d.b.h.c> c = new SparseArray();
    public final SparseArray<c.j.a.d.b.h.c> d = new SparseArray();
    public final SparseArray<c.j.a.d.b.h.c> e = new SparseArray();
    public final c0<Integer, c.j.a.d.b.h.c> f = new c0();
    public final SparseArray<Long> g = new SparseArray();
    public final LinkedBlockingDeque<c.j.a.d.b.h.c> h = new LinkedBlockingDeque();
    public final n i = c.j.a.d.b.e.b.x();
    public final f j = new f(Looper.getMainLooper(), this);

    /* compiled from: AbsDownloadEngine */
    public class a implements Runnable {
        public final /* synthetic */ int a;

        public a(c cVar, int i) {
            this.a = i;
        }

        public void run() {
            d.a().e(this.a);
        }
    }

    /* compiled from: AbsDownloadEngine */
    public class b implements Runnable {
        public final /* synthetic */ int a;
        public final /* synthetic */ boolean b;

        public b(int i, boolean z) {
            this.a = i;
            this.b = z;
        }

        public void run() {
            c.this.m(this.a);
            c cVar = c.this;
            int i = this.a;
            boolean z = this.b;
            synchronized (cVar) {
                try {
                    com.ss.android.socialbase.downloader.g.c b = cVar.i.b(i);
                    if (b != null) {
                        if (z) {
                            c.j.a.d.b.n.a.n(b, true);
                        } else {
                            c.j.a.d.b.n.a.L(b.k0(), b.l0());
                        }
                        b.Q();
                    }
                    cVar.i.f(i);
                } catch (SQLiteException e) {
                    e.printStackTrace();
                } catch (Throwable th) {
                    th.printStackTrace();
                }
                cVar.b(i, -4);
                if (cVar.c.get(i) != null) {
                    cVar.c.remove(i);
                }
                if (cVar.b.get(i) != null) {
                    cVar.b.remove(i);
                }
                synchronized (cVar.f) {
                    cVar.f.remove(Integer.valueOf(i));
                }
                c.j.a.d.b.l.a.j(i);
            }
            return;
        }
    }

    /* compiled from: AbsDownloadEngine */
    public class c implements Runnable {
        public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;
        public final /* synthetic */ c.j.a.d.b.d.b b;

        public c(c cVar, com.ss.android.socialbase.downloader.g.c cVar2, c.j.a.d.b.d.b bVar) {
            this.a = cVar2;
            this.b = bVar;
        }

        public void run() {
            com.ss.android.socialbase.downloader.g.c cVar = this.a;
            if (cVar != null && this.b != null) {
                if (cVar.o0() == -3) {
                    this.b.D(this.a);
                } else if (this.a.o0() == -1) {
                    this.b.z(this.a, new com.ss.android.socialbase.downloader.e.a(1000, "尝试为failed的任务add listener"));
                }
            }
        }
    }

    public abstract List<Integer> a();

    public void a(Message message) {
        int i = message.arg1;
        Object obj = message.obj;
        com.ss.android.socialbase.downloader.e.a aVar = obj instanceof Exception ? (com.ss.android.socialbase.downloader.e.a) obj : null;
        synchronized (c.class) {
            c.j.a.d.b.h.c cVar = (c.j.a.d.b.h.c) this.a.get(i);
            if (cVar == null) {
                return;
            }
            int i2 = message.what;
            com.ss.android.socialbase.downloader.g.c cVar2 = cVar.a;
            SparseArray a = cVar.a(g.MAIN);
            SparseArray a2 = cVar.a(g.NOTIFICATION);
            com.ss.android.socialbase.downloader.g.c cVar3 = cVar.a;
            boolean J = cVar3 != null ? cVar3.J() : false;
            i.l(i2, a, true, cVar2, aVar);
            i.l(i2, a2, J, cVar2, aVar);
            b(i, message.what);
        }
    }

    public synchronized void b(int i, int i2) {
        c.j.a.d.b.h.c cVar;
        if (i2 != -7) {
            if (i2 == -6) {
                this.b.put(i, (c.j.a.d.b.h.c) this.a.get(i));
                this.a.remove(i);
            } else if (i2 == -4) {
                this.a.remove(i);
                s(i);
            } else if (i2 == -3) {
                this.b.put(i, (c.j.a.d.b.h.c) this.a.get(i));
                this.a.remove(i);
                s(i);
            } else if (i2 != -1) {
                if (i2 == 7) {
                    cVar = (c.j.a.d.b.h.c) this.a.get(i);
                    if (cVar != null) {
                        if (this.d.get(i) == null) {
                            this.d.put(i, cVar);
                        }
                        this.a.remove(i);
                    }
                    s(i);
                } else if (i2 == 8) {
                    cVar = (c.j.a.d.b.h.c) this.a.get(i);
                    if (cVar != null && this.e.get(i) == null) {
                        this.e.put(i, cVar);
                    }
                    s(i);
                }
            }
        }
        cVar = (c.j.a.d.b.h.c) this.a.get(i);
        if (cVar != null) {
            if (this.c.get(i) == null) {
                this.c.put(i, cVar);
            }
            this.a.remove(i);
        }
        s(i);
    }

    public synchronized void c(int i, int i2, c.j.a.d.b.d.b bVar, g gVar, boolean z, boolean z2) {
        g gVar2 = g.NOTIFICATION;
        synchronized (this) {
            c.j.a.d.b.h.c r = r(i);
            if (r != null) {
                r.g(i2, bVar, gVar, z);
                com.ss.android.socialbase.downloader.g.c cVar = r.a;
                if (z2 && cVar != null && !j(i) && (gVar == g.MAIN || gVar == gVar2)) {
                    Object obj = 1;
                    if (gVar == gVar2 && !cVar.J()) {
                        obj = null;
                    }
                    if (obj != null) {
                        this.j.post(new c(this, cVar, bVar));
                    }
                }
            } else if (i.s(32768)) {
                com.ss.android.socialbase.downloader.g.c b = this.i.b(i);
                if (!(b == null || b.o0() == -3)) {
                    c.j.a.d.b.h.c cVar2 = (c.j.a.d.b.h.c) this.f.get(Integer.valueOf(i));
                    if (cVar2 == null) {
                        cVar2 = new c.j.a.d.b.h.c();
                        cVar2.a = b;
                        synchronized (this.f) {
                            this.f.put(Integer.valueOf(i), cVar2);
                        }
                    }
                    cVar2.g(i2, bVar, gVar, z);
                }
            }
        }
    }

    public abstract void d(int i, long j);

    public abstract void e(int i, c.j.a.d.b.h.c cVar);

    public final void f(com.ss.android.socialbase.downloader.g.c cVar) {
        h hVar = h.DELAY_RETRY_NONE;
        try {
            if (cVar.o0() == 7 || cVar.G != hVar) {
                cVar.b0(5);
                cVar.G = hVar;
                AlarmManager p = c.j.a.d.b.e.b.p();
                Intent intent = new Intent("com.ss.android.downloader.action.DOWNLOAD_WAKEUP");
                intent.putExtra("extra_download_id", cVar.g0());
                intent.setClass(c.j.a.d.b.e.b.a(), DownloadHandleService.class);
                p.cancel(PendingIntent.getService(c.j.a.d.b.e.b.a(), cVar.g0(), intent, 1073741824));
                c.j.a.d.b.g.a.d("AbsDownloadEngine", "cancelAlarm");
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public void g(c.j.a.d.b.h.c cVar) {
        if (cVar != null) {
            com.ss.android.socialbase.downloader.g.c cVar2 = cVar.a;
            if (cVar2 != null) {
                cVar2.G0 = false;
                if (cVar2.l0 == c.j.a.d.b.b.f.ENQUEUE_NONE) {
                    h(cVar, true);
                } else if (cVar2 != null) {
                    try {
                        synchronized (this.h) {
                            if (this.h.isEmpty()) {
                                h(cVar, true);
                                this.h.put(cVar);
                            } else if (cVar2.l0 != c.j.a.d.b.b.f.ENQUEUE_TAIL) {
                                c.j.a.d.b.h.c cVar3 = (c.j.a.d.b.h.c) this.h.getFirst();
                                if (cVar3.m() == cVar.m() && j(cVar.m())) {
                                } else {
                                    o(cVar3.m());
                                    h(cVar, true);
                                    if (cVar3.m() != cVar.m()) {
                                        this.h.putFirst(cVar);
                                    }
                                }
                            } else if (((c.j.a.d.b.h.c) this.h.getFirst()).m() == cVar.m() && j(cVar.m())) {
                            } else {
                                Iterator it = this.h.iterator();
                                while (it.hasNext()) {
                                    c.j.a.d.b.h.c cVar4 = (c.j.a.d.b.h.c) it.next();
                                    if (cVar4 != null && cVar4.m() == cVar.m()) {
                                        it.remove();
                                        break;
                                    }
                                }
                                this.h.put(cVar);
                                new c.j.a.d.b.e.h(cVar, this.j).a();
                            }
                        }
                    } catch (InterruptedException unused) {
                    }
                }
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:108:0x0195  */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x014c  */
    public final void h(c.j.a.d.b.h.c r11, boolean r12) {
        /*
        r10 = this;
        r0 = r11.a;
        if (r0 != 0) goto L_0x0005;
    L_0x0004:
        return;
    L_0x0005:
        r1 = r0.E();
        r2 = 1003; // 0x3eb float:1.406E-42 double:4.955E-321;
        if (r1 == 0) goto L_0x003f;
    L_0x000d:
        r11 = r11.l;
        r12 = new com.ss.android.socialbase.downloader.e.a;
        r1 = "downloadInfo is Invalid, url is ";
        r1 = c.b.a.a.a.g(r1);
        r3 = r0.d;
        r1.append(r3);
        r3 = " name is ";
        r1.append(r3);
        r3 = r0.b;
        r1.append(r3);
        r3 = " savePath is ";
        r1.append(r3);
        r3 = r0.e;
        r1.append(r3);
        r1 = r1.toString();
        r12.m4677init(r2, r1);
        r1 = r0.o0();
        c.j.a.c.y.a.i.n(r11, r0, r12, r1);
        return;
    L_0x003f:
        r1 = r0.g0();
        if (r12 == 0) goto L_0x0048;
    L_0x0045:
        r10.f(r0);
    L_0x0048:
        r12 = r10.c;
        monitor-enter(r12);
        r3 = r10.c;	 Catch:{ all -> 0x01c6 }
        r3 = r3.get(r1);	 Catch:{ all -> 0x01c6 }
        if (r3 == 0) goto L_0x0058;
    L_0x0053:
        r3 = r10.c;	 Catch:{ all -> 0x01c6 }
        r3.remove(r1);	 Catch:{ all -> 0x01c6 }
    L_0x0058:
        monitor-exit(r12);	 Catch:{ all -> 0x01c6 }
        r3 = r10.b;
        monitor-enter(r3);
        r12 = r10.b;	 Catch:{ all -> 0x01c3 }
        r12 = r12.get(r1);	 Catch:{ all -> 0x01c3 }
        if (r12 == 0) goto L_0x0069;
    L_0x0064:
        r12 = r10.b;	 Catch:{ all -> 0x01c3 }
        r12.remove(r1);	 Catch:{ all -> 0x01c3 }
    L_0x0069:
        monitor-exit(r3);	 Catch:{ all -> 0x01c3 }
        r12 = r10.d;
        monitor-enter(r12);
        r3 = r10.d;	 Catch:{ all -> 0x01c0 }
        r3 = r3.get(r1);	 Catch:{ all -> 0x01c0 }
        if (r3 == 0) goto L_0x007a;
    L_0x0075:
        r3 = r10.d;	 Catch:{ all -> 0x01c0 }
        r3.remove(r1);	 Catch:{ all -> 0x01c0 }
    L_0x007a:
        monitor-exit(r12);	 Catch:{ all -> 0x01c0 }
        r3 = r10.e;
        monitor-enter(r3);
        r12 = r10.e;	 Catch:{ all -> 0x01bd }
        r12 = r12.get(r1);	 Catch:{ all -> 0x01bd }
        if (r12 == 0) goto L_0x008b;
    L_0x0086:
        r12 = r10.e;	 Catch:{ all -> 0x01bd }
        r12.remove(r1);	 Catch:{ all -> 0x01bd }
    L_0x008b:
        monitor-exit(r3);	 Catch:{ all -> 0x01bd }
        r12 = 512; // 0x200 float:7.175E-43 double:2.53E-321;
        r12 = c.j.a.c.y.a.i.s(r12);
        if (r12 == 0) goto L_0x00b5;
    L_0x0094:
        r12 = r10.j(r1);
        if (r12 == 0) goto L_0x00b5;
    L_0x009a:
        r12 = r10.a;
        monitor-enter(r12);
        r3 = r10.a;	 Catch:{ all -> 0x00b2 }
        r3 = r3.get(r1);	 Catch:{ all -> 0x00b2 }
        r3 = (c.j.a.d.b.h.c) r3;	 Catch:{ all -> 0x00b2 }
        if (r3 == 0) goto L_0x00ab;
    L_0x00a7:
        r3.e(r11);	 Catch:{ all -> 0x00b2 }
        goto L_0x00b0;
    L_0x00ab:
        r3 = r10.a;	 Catch:{ all -> 0x00b2 }
        r3.put(r1, r11);	 Catch:{ all -> 0x00b2 }
    L_0x00b0:
        monitor-exit(r12);	 Catch:{ all -> 0x00b2 }
        goto L_0x00b5;
    L_0x00b2:
        r11 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x00b2 }
        throw r11;
    L_0x00b5:
        r12 = r10.j(r1);
        if (r12 == 0) goto L_0x00e0;
    L_0x00bb:
        r12 = r0.z();
        if (r12 != 0) goto L_0x00e0;
    L_0x00c1:
        r12 = "AbsDownloadEngine";
        r1 = "another task with same id is downloading when tryDownload";
        c.j.a.d.b.g.a.d(r12, r1);
        r12 = r0.w0;
        if (r12 == 0) goto L_0x00cf;
    L_0x00cc:
        r11.n();
    L_0x00cf:
        r11 = r11.l;
        r12 = new com.ss.android.socialbase.downloader.e.a;
        r1 = "downloadInfo is isDownloading and addListenerToSameTask is false";
        r12.m4677init(r2, r1);
        r1 = r0.o0();
        c.j.a.c.y.a.i.n(r11, r0, r12, r1);
        return;
    L_0x00e0:
        r12 = r0.z();
        if (r12 == 0) goto L_0x00ea;
    L_0x00e6:
        r12 = c.j.a.d.b.b.a.ASYNC_HANDLE_RESTART;
        r0.I = r12;
    L_0x00ea:
        r12 = 32768; // 0x8000 float:4.5918E-41 double:1.61895E-319;
        r12 = c.j.a.c.y.a.i.s(r12);
        if (r12 == 0) goto L_0x010c;
    L_0x00f3:
        r12 = r10.f;
        monitor-enter(r12);
        r3 = r10.f;	 Catch:{ all -> 0x0109 }
        r4 = java.lang.Integer.valueOf(r1);	 Catch:{ all -> 0x0109 }
        r3 = r3.remove(r4);	 Catch:{ all -> 0x0109 }
        r3 = (c.j.a.d.b.h.c) r3;	 Catch:{ all -> 0x0109 }
        monitor-exit(r12);	 Catch:{ all -> 0x0109 }
        if (r3 == 0) goto L_0x010c;
    L_0x0105:
        r11.i(r3);
        goto L_0x010c;
    L_0x0109:
        r11 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x0109 }
        throw r11;
    L_0x010c:
        r12 = r10.a;
        monitor-enter(r12);
        r3 = r10.g;	 Catch:{ all -> 0x01ba }
        r3 = r3.get(r1);	 Catch:{ all -> 0x01ba }
        r3 = (java.lang.Long) r3;	 Catch:{ all -> 0x01ba }
        if (r3 == 0) goto L_0x011e;
    L_0x0119:
        r3 = r3.longValue();	 Catch:{ all -> 0x01ba }
        goto L_0x0120;
    L_0x011e:
        r3 = 0;
    L_0x0120:
        r5 = android.os.SystemClock.uptimeMillis();	 Catch:{ all -> 0x01ba }
        r3 = r5 - r3;
        r7 = 50;
        r9 = (r3 > r7 ? 1 : (r3 == r7 ? 0 : -1));
        if (r9 >= 0) goto L_0x01a7;
    L_0x012c:
        r3 = r10.a;	 Catch:{ all -> 0x01ba }
        r3 = r3.get(r1);	 Catch:{ all -> 0x01ba }
        r3 = (c.j.a.d.b.h.c) r3;	 Catch:{ all -> 0x01ba }
        r4 = 0;
        if (r3 == 0) goto L_0x0149;
    L_0x0137:
        r3 = r3.a;	 Catch:{ all -> 0x01ba }
        if (r3 == 0) goto L_0x0149;
    L_0x013b:
        r3 = r3.o0();	 Catch:{ all -> 0x01ba }
        if (r3 != 0) goto L_0x014a;
    L_0x0141:
        r7 = c.j.a.c.y.a.i.x(r3);	 Catch:{ all -> 0x01ba }
        if (r7 == 0) goto L_0x014a;
    L_0x0147:
        r4 = 1;
        goto L_0x014a;
    L_0x0149:
        r3 = 0;
    L_0x014a:
        if (r4 == 0) goto L_0x0195;
    L_0x014c:
        r4 = "AbsDownloadEngine";
        r7 = new java.lang.StringBuilder;	 Catch:{ all -> 0x01ba }
        r7.<init>();	 Catch:{ all -> 0x01ba }
        r8 = "can add listener, oldTaskStatus is :";
        r7.append(r8);	 Catch:{ all -> 0x01ba }
        r7.append(r3);	 Catch:{ all -> 0x01ba }
        r7 = r7.toString();	 Catch:{ all -> 0x01ba }
        c.j.a.d.b.g.a.d(r4, r7);	 Catch:{ all -> 0x01ba }
        if (r3 < 0) goto L_0x016b;
    L_0x0164:
        r4 = 2;
        if (r3 >= r4) goto L_0x016b;
    L_0x0167:
        r11.n();	 Catch:{ all -> 0x01ba }
        goto L_0x01b8;
    L_0x016b:
        r3 = r0.w0;	 Catch:{ all -> 0x01ba }
        if (r3 == 0) goto L_0x0173;
    L_0x016f:
        r11.n();	 Catch:{ all -> 0x01ba }
        goto L_0x01b8;
    L_0x0173:
        r3 = r11.l;	 Catch:{ all -> 0x01ba }
        r4 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ all -> 0x01ba }
        r7 = "has another same task within 50 milliseconds and addListenerToSameTask is false";
        r4.m4677init(r2, r7);	 Catch:{ all -> 0x01ba }
        r2 = r0.o0();	 Catch:{ all -> 0x01ba }
        c.j.a.c.y.a.i.n(r3, r0, r4, r2);	 Catch:{ all -> 0x01ba }
        r0 = r10.a;	 Catch:{ all -> 0x01ba }
        r0.put(r1, r11);	 Catch:{ all -> 0x01ba }
        r0 = r10.g;	 Catch:{ all -> 0x01ba }
        r2 = java.lang.Long.valueOf(r5);	 Catch:{ all -> 0x01ba }
        r0.put(r1, r2);	 Catch:{ all -> 0x01ba }
        r10.e(r1, r11);	 Catch:{ all -> 0x01ba }
        goto L_0x01b8;
    L_0x0195:
        r0 = r10.a;	 Catch:{ all -> 0x01ba }
        r0.put(r1, r11);	 Catch:{ all -> 0x01ba }
        r0 = r10.g;	 Catch:{ all -> 0x01ba }
        r2 = java.lang.Long.valueOf(r5);	 Catch:{ all -> 0x01ba }
        r0.put(r1, r2);	 Catch:{ all -> 0x01ba }
        r10.e(r1, r11);	 Catch:{ all -> 0x01ba }
        goto L_0x01b8;
    L_0x01a7:
        r0 = r10.a;	 Catch:{ all -> 0x01ba }
        r0.put(r1, r11);	 Catch:{ all -> 0x01ba }
        r0 = r10.g;	 Catch:{ all -> 0x01ba }
        r2 = java.lang.Long.valueOf(r5);	 Catch:{ all -> 0x01ba }
        r0.put(r1, r2);	 Catch:{ all -> 0x01ba }
        r10.e(r1, r11);	 Catch:{ all -> 0x01ba }
    L_0x01b8:
        monitor-exit(r12);	 Catch:{ all -> 0x01ba }
        return;
    L_0x01ba:
        r11 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x01ba }
        throw r11;
    L_0x01bd:
        r11 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x01bd }
        throw r11;
    L_0x01c0:
        r11 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x01c0 }
        throw r11;
    L_0x01c3:
        r11 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x01c3 }
        throw r11;
    L_0x01c6:
        r11 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x01c6 }
        throw r11;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.j.c.h(c.j.a.d.b.h.c, boolean):void");
    }

    public abstract void i(c.j.a.d.b.m.c cVar);

    public abstract boolean j(int i);

    public abstract void k(int i);

    public void l(int i, boolean z) {
        com.ss.android.socialbase.downloader.g.c b = this.i.b(i);
        if (b != null) {
            f(b);
        }
        this.j.post(new a(this, i));
        c.j.a.d.b.e.b.k(new b(i, z), true);
    }

    public abstract c.j.a.d.b.m.c m(int i);

    public com.ss.android.socialbase.downloader.g.c n(int i) {
        com.ss.android.socialbase.downloader.g.c b = this.i.b(i);
        if (b == null) {
            synchronized (this.a) {
                c.j.a.d.b.h.c cVar = (c.j.a.d.b.h.c) this.a.get(i);
                if (cVar != null) {
                    b = cVar.a;
                }
            }
        }
        return b;
    }

    public boolean o(int i) {
        c.j.a.d.b.g.a.d("AbsDownloadEngine", "pause id");
        com.ss.android.socialbase.downloader.g.c b = this.i.b(i);
        if (b != null && b.o0() == 11) {
            return false;
        }
        k(i);
        c.j.a.d.b.h.c cVar;
        if (b == null) {
            synchronized (this.a) {
                cVar = (c.j.a.d.b.h.c) this.a.get(i);
                if (cVar != null) {
                    new c.j.a.d.b.e.h(cVar, this.j).i();
                    return true;
                }
            }
        }
        f(b);
        if (b.o0() == 1) {
            synchronized (this.a) {
                cVar = (c.j.a.d.b.h.c) this.a.get(i);
                if (cVar != null) {
                    new c.j.a.d.b.e.h(cVar, this.j).i();
                    return true;
                }
            }
        } else if (i.x(b.o0())) {
            b.b0(-2);
            return true;
        }
        return false;
    }

    public synchronized boolean p(int i) {
        c.j.a.d.b.h.c cVar = (c.j.a.d.b.h.c) this.c.get(i);
        if (cVar == null) {
            cVar = (c.j.a.d.b.h.c) this.d.get(i);
        }
        if (cVar == null) {
            return false;
        }
        com.ss.android.socialbase.downloader.g.c cVar2 = cVar.a;
        if (cVar2 != null) {
            cVar2.G0 = false;
        }
        g(cVar);
        return true;
    }

    public synchronized boolean q(int i) {
        c.j.a.d.b.h.c cVar = (c.j.a.d.b.h.c) this.e.get(i);
        if (cVar != null) {
            com.ss.android.socialbase.downloader.g.c cVar2 = cVar.a;
            if (cVar2 != null) {
                if (cVar2.z()) {
                    g(cVar);
                }
                return true;
            }
        }
        return false;
    }

    public final c.j.a.d.b.h.c r(int i) {
        c.j.a.d.b.h.c cVar = (c.j.a.d.b.h.c) this.a.get(i);
        if (cVar != null) {
            return cVar;
        }
        cVar = (c.j.a.d.b.h.c) this.c.get(i);
        if (cVar != null) {
            return cVar;
        }
        cVar = (c.j.a.d.b.h.c) this.b.get(i);
        if (cVar != null) {
            return cVar;
        }
        cVar = (c.j.a.d.b.h.c) this.d.get(i);
        return cVar == null ? (c.j.a.d.b.h.c) this.e.get(i) : cVar;
    }

    /* JADX WARNING: Missing block: B:19:0x003a, code skipped:
            return;
     */
    public final void s(int r3) {
        /*
        r2 = this;
        r0 = r2.h;
        r0 = r0.isEmpty();
        if (r0 == 0) goto L_0x0009;
    L_0x0008:
        return;
    L_0x0009:
        r0 = r2.h;
        monitor-enter(r0);
        r1 = r2.h;	 Catch:{ all -> 0x003b }
        r1 = r1.getFirst();	 Catch:{ all -> 0x003b }
        r1 = (c.j.a.d.b.h.c) r1;	 Catch:{ all -> 0x003b }
        if (r1 == 0) goto L_0x0021;
    L_0x0016:
        r1 = r1.m();	 Catch:{ all -> 0x003b }
        if (r1 != r3) goto L_0x0021;
    L_0x001c:
        r3 = r2.h;	 Catch:{ all -> 0x003b }
        r3.poll();	 Catch:{ all -> 0x003b }
    L_0x0021:
        r3 = r2.h;	 Catch:{ all -> 0x003b }
        r3 = r3.isEmpty();	 Catch:{ all -> 0x003b }
        if (r3 == 0) goto L_0x002b;
    L_0x0029:
        monitor-exit(r0);	 Catch:{ all -> 0x003b }
        return;
    L_0x002b:
        r3 = r2.h;	 Catch:{ all -> 0x003b }
        r3 = r3.getFirst();	 Catch:{ all -> 0x003b }
        r3 = (c.j.a.d.b.h.c) r3;	 Catch:{ all -> 0x003b }
        if (r3 == 0) goto L_0x0039;
    L_0x0035:
        r1 = 1;
        r2.h(r3, r1);	 Catch:{ all -> 0x003b }
    L_0x0039:
        monitor-exit(r0);	 Catch:{ all -> 0x003b }
        return;
    L_0x003b:
        r3 = move-exception;
        monitor-exit(r0);	 Catch:{ all -> 0x003b }
        throw r3;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.j.c.s(int):void");
    }
}
